﻿using HDF5DotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace satellite_helper.Class
{
    class GetHdf5DataSet
    {
        public string[] hdf5_getDataSet(string fileName)
        {
            H5FileId fileId = H5F.open(fileName, H5F.OpenMode.ACC_RDONLY);
            H5GroupId groupId = H5G.open(fileId, "/");
            ulong num_objs = (ulong)H5G.getNumObjects(groupId);
            int num = Convert.ToInt32(num_objs);
            string[] dataNames = new string[num];
            ulong idxi = 0;

            for (int i = 0; i < num; i++)
            {
                idxi = (ulong)i;
                string name = H5G.getObjectNameByIndex(groupId, idxi);
                dataNames[i] = name;
            }

            H5G.close(groupId);
            H5F.close(fileId);
            return dataNames;
        }

        public string[] hdf5_getData(string fileName)
        {
            H5FileId fileId = H5F.open(fileName, H5F.OpenMode.ACC_RDONLY);
            H5GroupId groupId = H5G.open(fileId, "/");
            ulong num_objs = (ulong)H5G.getNumObjects(groupId);
            int num = Convert.ToInt32(num_objs);
            string[] dataNames = new string[num];
            ulong idxi = 0;

            for (int i = 0; i < num; i++)
            {
                idxi = (ulong)i;
                string name = H5G.getObjectNameByIndex(groupId, idxi);
                dataNames[i] = name;
            }

            H5G.close(groupId);
            H5F.close(fileId);
            return dataNames;
        }
    }
}
